package com.ibm.eg.cvmanager.business.layer;

import java.util.ArrayList;

import com.ibm.eg.cvmanager.business.interfaces.InterviewerBusiness;
import com.ibm.eg.cvmanager.dao.impl.InterviewDao;
import com.ibm.eg.cvmanager.dao.impl.InterviewerDao;
import com.ibm.eg.cvmanager.dto.Applicant;
import com.ibm.eg.cvmanager.dto.Interviewer;
import com.ibm.eg.cvmanager.dto.InterviewerId;

import exception.TechnicalException;


public class InterviewerBusinessImpl implements InterviewerBusiness 
{
	public void addInterviewer(Interviewer interviewer)
	{
		InterviewerDao x =new InterviewerDao();
		try
		{
			x.beginTransaction();
			x.add(interviewer);
			x.commitTransaction();
		}
		catch(Exception re)
		{
			x.rollbackTransaction();
		}
	}
	
	public void updateInterviewer(Interviewer interviewer,String newname)
	{
		InterviewerDao x =new InterviewerDao();
		try
		{
			x.beginTransaction();
			x.update(interviewer);
			x.commitTransaction();
		}
		catch(Exception re)
		{
			x.rollbackTransaction();
		}
	}
	
	public void deleteInterviewer(int id)
	{
		InterviewerId inid = new InterviewerId();
		inid.setInterviewId(id);
		Interviewer inter = new Interviewer();
		inter.setId(inid);
		InterviewerDao x =new InterviewerDao();
		
		try
		{
			x.beginTransaction();
			x.delete(inter);
			x.commitTransaction();
		}
		catch(Exception re)
		{
			x.rollbackTransaction();
		}
	}
	
	public ArrayList<Interviewer>filterInterviewer(String name) throws TechnicalException
	{
		InterviewerDao x =new InterviewerDao();		
		return x.filterInterviewer(name);
	}

}
